<?php
namespace lactone\Core\Queue\Driver;

class ShmopDriver implements QueueDriverInterface{

    public  $key = 'Shmop';

    public  $size = 100;

    public  $moduel;

    protected $shmop_id;

    public function push($data){

    }

    public function shift(){

    }

    public function isEmpty(){

    }

    /**
     * 初始化配置
     * @param $Configs
     * @return bool
     */
    public function initConfig($Configs){
        foreach($Configs as $key => $value){
            $this->$key = $value;
        }
        return true;
    }

    public function reset(){
        return true;
    }

    /**
     * 获取内存，如果没有生成就自动生成一下
     * @throws \Exception
     */
    public function getShmop(){

        if(!$this->shmop_id){
            $shm_key = ftok(__FILE__.$this->key, 'c');

            if(!$shm_id = shmop_open($shm_key, "c", 0644, 100)){
                throw new \Exception("内存申请失败!");
            }

        }
    }


}
?>